const {ccclass, property} = cc._decorator;

@ccclass
export class SnakeBody extends cc.Component {

    @property(cc.SpriteAtlas)
    atlas:cc.SpriteAtlas;
    @property(cc.Sprite)
    bodySprite:cc.Sprite;

    _skinType:number = 1;
    _skinIndex:number = 1;

    public onLoad() {
        // init logic

    }

    public init(pos:cc.Vec2, zOrder:number, skinType:number, skinIndex:number) {

        this.bodySprite.spriteFrame = this.atlas.getSpriteFrame("skin_" + skinType + "_" + skinIndex);
        this.node.setPosition(pos);
        this.node.zIndex = zOrder;
    }

    public setScale(scale:number) {
        this.node.scale = scale;
    }

    public setPos(pos:cc.Vec2) {
        this.node.setPosition(pos);
    }

    public getPos():cc.Vec2 {
        return this.node.getPosition();
    }

    public setRotation(rotation:number) {
        this.node.rotation = rotation;
    }

}
